package com.itheima.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(1)
@Slf4j
@Aspect
@Component
public class MyAspect1 {

//    @Pointcut("execution(* com.itheima.service.impl.DeptServiceImpl.*(..))")

    @Pointcut("@annotation(com.itheima.aop.Log)")
    public void pt(){}

    @Around("pt()")
    public Object around(ProceedingJoinPoint pjp) throws  Throwable{
        log.info("around 环绕前通知");
        Object result = pjp.proceed();
        log.info("around 环绕后通知");

        return result;
    }

    @Before("pt()")
    public void before(){
        log.info("before");
    }

    @After("pt()")
    public void after(){
        log.info("after");

    }

    @AfterReturning("pt()")
    public void afterReturn(){
        log.info("afterReturn");

    }

    @AfterThrowing("pt()")
    public void afterThrowing(){
        log.info("afterThrowing");
    }

}
